package com.lagou.homework3;

public class Ticket1 implements Runnable {
    private int tickets = 100;
    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (tickets <= 0) {
                    break;
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程" + Thread.currentThread().getName() +"...第" + (tickets--) + "号票");
            }
        }
    }
}
